package com.tongtech.space.controller.common;

import com.tongtech.space.common.constants.Constants;
import com.tongtech.space.common.pojo.Result;
import com.tongtech.space.module.common.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Redis测试类
 *
 * @author jinjiayu
 * @since 2022/1/26
 */
@RequestMapping(Constants.URL_API_VERSION + "/test/redis")
@RestController
@Api(tags = "测试-redis")
public class TestRedisController {

    @Autowired
    private TestService testService;

    @ApiOperation(value = "redis-新增缓存")
    @GetMapping("/redisCreate")
    public void redisCreate(String key, String value, int timeMinutes) {
        testService.redisCreate(key, value, timeMinutes);
    }

    @ApiOperation(value = "redis-模糊查询(如 abc 或 abc*)")
    @GetMapping("/redisKeyValueQuery")
    public Result redisKeyValueQuery(String pattern) {
        return testService.redisKeyValueQuery(pattern);
    }

    @ApiOperation(value = "redis-模糊删除(如 abc 或 abc*)")
    @GetMapping("/redisDeleteBatch")
    public Result redisDeleteBatch(String pattern) {
        return testService.redisDeleteBatch(pattern);
    }

    @ApiOperation("redisson测试分布式锁的实现")
    @GetMapping("/redissonLockTest")
    public void redissonLockTest() {
        testService.redissonLockTest();
    }

}
